import request from '@/utils/request'

/** *
 * 获取角色列表
 * **/
export const getRoleListApi = (params) => request.get('/sys/role', {
  params
})

export const addRoleApi = (data) => request.post('/sys/role', data)

export function updateRoleApi(data) {
  return request({
    url: `/sys/role/${data.id}`,
    method: 'put',
    data
  })
}

/** *
 * 删除角色
 * **/

export function delRoleApi(id) {
  return request({
    url: `/sys/role/${id}`,
    method: 'delete'
  })
}

/**
 * 获取可用的角色
 * **/

export const getEnableRoleListApi = () => request.get('/sys/role/list/enabled')

/**
 * 分配员工角色
 * ***/

export function assignRoleApi(data) {
  return request({
    url: '/sys/user/assignRoles',
    method: 'put',
    data
  })
}

export function getRoleDetailApi(id) {
  return request({
    url: `/sys/role/${id}`
  })
}

/**
 * 给角色分配权限
 *
 * ***/

export function assignPermApi(data) {
  return request({
    url: '/sys/role/assignPrem',
    method: 'put',
    data
  })
}
